<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function doSomething(){
            // var username = document.getElementById('username')
            // console.log(username.value)
            // username.value = 'lucy'

            var male = document.getElementById('male')
            // console.log(male.checked) // true表示选中,false表示未选中
            if(male.checked){
                console.log(male.value)
            }else{
                console.log(document.getElementById('female').value)
            }
        }
    </script>
</head>
<body>
    <button onclick="doSomething()">点我</button>
    <hr>

    用户名: <input type="text" id="username" value="jack"> <br>
    性别: <input type="radio" name="sex" value="male" id="male" checked>男
         <input type="radio" name="sex" value="female" id="female">女 <br>
    </input>
</body>
</html>